home *** CD-ROM | disk | FTP | other *** search
- Script:ReloadScript( "SCRIPTS/Default/Entities/AI/MutantRear_x.lua");
- MutantRear=CreateAI(MutantRear_x)
- ------------------------------------------------------------------------------------
-
- -- activate mutant stealth
- function MutantRear:GoRefractive()
- -- for some reason, this is called lots of times
- if(self.isRefractive~=1) then
- self.refractionSwitchDirection = 1;
- self.refractionValue = 0.15;
- self.isRefractive=1;
- self.iPlayerEffect=5;
-
- AI:Signal(SIGNALID_READIBILITY, 1, "VISIBLE_TO_REFRACTIVE",self.id);
-
- end
- end
-
- -- deactivate mutant stealth
- function MutantRear:GoVisible()
- -- for some reason, this is being called lots of times
- --if(self.refractionSwitchDirection~=2 and self.isRefractive==1) then
-
- self.refractionSwitchDirection = 2;
- -- died, go visible
- if (self.cnt.health < 1) then
- self:ResetStealth();
- end
-
- AI:Signal(SIGNALID_READIBILITY, 1, "REFRACTIVE_TO_VISIBLE",self.id);
- --end
- end
-
- -- dehactivate stealth when entity gets damage
- function MutantRear:OnDamageCustom()
- self:GoVisible();
- end
-
- -- update stealth
- function MutantRear:Client_OnTimerCustom()
- -- no stealth ?
- if(self.refractionSwitchDirection==0) then
- return nil;
- end
-
- if(self.cnt.health < 1) then
- self:ResetStealth();
- return nil;
- end
-
- -- set stealth
- self.isRefractive=1;
-
- --stealth not active ?
- --if(self.iPlayerEffect~=5 and ClientStuff and ClientStuff.vlayers and not ClientStuff.vlayers:IsActive("HeatVision"))then
- self.iPlayerEffect=5;
- --end
-
- -- go invisible
- if(self.refractionSwitchDirection==1) then
- -- interpolate refraction amount
- local refrLimit =.01;
- self.refractionValue= self.refractionValue+(refrLimit-self.refractionValue)*_frametime*50;
-
- -- clamp to refraction minimum limit
- if( self.refractionValue<refrLimit+0.01 ) then
- self.refractionValue = refrLimit;
- end
- elseif(self.refractionSwitchDirection==2) then -- go visible
- -- interpolate refraction amount
- local refrLimit =0.15;
- self.refractionValue= self.refractionValue+(refrLimit-self.refractionValue)*_frametime*50;
-
- -- reset state
- if(self.refractionValue>refrLimit-0.01 ) then
- self.refractionValue = refrLimit;
- self:ResetStealth();
- end
- end
-
- -- update refraction shader value
- self:SetShaderFloat("Refraction", self.refractionValue, 0, 1);
- end
-
- -- reset states
- function MutantRear:OnResetCustom()
- if (self.Properties.fileBackpackModel) then
- self:LoadObject( self.Properties.fileBackpackModel,1,0);
- self:AttachObjectToBone( 1, "Bip01 Spine2" );
- end
-
- self:GoRefractive();
- end
-
- function MutantRear:ResetStealth()
-
- -- reset shader
- --if(ClientStuff and ClientStuff.vlayers and not ClientStuff.vlayers:IsActive("HeatVision")) then
- self.iPlayerEffect=1;
- --end
-
- self.refractionSwitchDirection = 0;
- self.refractionValue = 0.15;
- self.isRefractive=0;
- end